Skip to content

[ARCH]Add SiameseNorm and DepthAttention architecture - #19

Open
franksfc wants to merge 4 commits into
InternLM:arch/depth-attn-siamese-normfrom
franksfc:arch/SiameseNorm-DepthAttention
Open

[ARCH]Add SiameseNorm and DepthAttention architecture#19
franksfc wants to merge 4 commits into
InternLM:arch/depth-attn-siamese-normfrom
franksfc:arch/SiameseNorm-DepthAttention

Conversation

@franksfc

@franksfc franksfc commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Architecture Proposal

#2

Implementation Details

This PR implements SiameseNorm + Depth-Attention on top of the OLMo 3 decoder architecture and includes the reproducible Ascend/MindSpeed training pipeline used for the current model artifacts.

Modified components

  • Added separate base and siamese_depth OLMo 3 model variants.
  • Added forward-local dual residual-stream state for SiameseNorm.
  • Added sparse cross-layer Depth-Attention before ordinary token attention.
  • Preserved OLMo 3 Q/K normalization, RoPE, MLP, tokenizer, causal masking, and the [SWA, SWA, SWA, Full] attention pattern.
  • Added Stage 1 pretraining, Stage 2 mid-training, Stage 3 long-context training, and Stage 4 Think/Instruct SFT configuration and launch paths.
  • Added checkpoint save/resume/transition validation, native inference, 65K KV-cache validation, PPL evaluation, and OLMES objective-evaluation entry points.
  • Added Transformers remote-code inference files under archs/SiameseNorm-DepthAttention.
  • Added the reproducible Megatron/MindSpeed pipeline under reproduce/Megatron-LM.

Key implementation details

  • SiameseNorm maintains two forward-local residual streams while sharing each attention and MLP computation. For layer l, the Post-Norm-like stream receives the depth-scaled update Δ / sqrt(2l), while the Pre-Norm-like stream receives the full update Δ.
  • Depth-Attention is applied after Q/K normalization and RoPE, but before SWA or Full Attention.
  • The current query selects among the current layer and sparse earlier-layer K/V states at the same token position. The default source stride is 8.
  • The mixed value is passed into the original token-attention operation and written to the inference KV cache.
  • Depth-Attention adds no learned parameters or separate persistent cache.
  • Stage 3 and Stage 4 apply YaRN only to Full-Attention layers, supporting contexts up to 65,536 tokens.
  • SWA layers retain the original RoPE and a 4,096-token attention window.
  • Base and modified models use separate, strictly validated checkpoint keyspaces.
  • Checkpoint save, resume, topology migration, and Stage 1 → Stage 2 → Stage 3 → Stage 4 transitions are included in the pipeline.

Compatibility considerations

  • The published 1B artifacts use standard Transformers remote-code format and were release-validated with BF16 SDPA.
  • The native training path targets Megatron/MindSpeed on Ascend NPUs.
  • Third-party revisions are pinned, while deployment-specific paths, cluster configuration, and credentials remain outside version control.
  • Model construction is available for the repository's OLMo 3 1B, 3B, and 7B presets.
  • End-to-end four-stage training and checkpoint publication have been completed for the modified 1B model.
  • A matched OLMo 3 1B baseline has also completed, enabling a controlled preliminary comparison.
  • The modified 3B experiment is still training.
  • The 7B experimental plan is currently suspended.

Current scope and limitations

  • This remains a draft implementation PR, not a completed multi-scale architectural-effectiveness claim.
  • The modified four-stage checkpoints of OLMo 3 1B and its matched baseline have been published, and its downstream evaluation are complete.
  • Training curves indicate faster early-stage convergence for SiameseNorm + Depth-Attention relative to the matched baseline.
  • However, the final 1B downstream difference is small: the modified model reaches a 36.9 eight-task macro average, compared with 36.8 for the matched OLMo 3 baseline.
  • The 1B results are therefore mixed and do not yet establish a substantial final quality improvement.
  • The modified 3B experiment remains in progress.
  • The 7B experimental plan is suspended and is not part of the currently active training schedule.

Experimental Validation

Research Question 1 — Does the implementation preserve OLMo 3 training, checkpoint, and long-context inference semantics?

Hypothesis: SiameseNorm and Depth-Attention can be integrated without breaking the four-stage OLMo 3 pipeline, checkpoint transitions, SWA/Full-Attention behavior, or 65K inference.

Results & Analysis:

The modified 1B model completed and published the following artifacts:

Stage Iteration Training context length Status
Stage 1 pretraining 89,407 8,192 Published
Stage 2 mid-training 47,684 8,192 Published
Stage 3 long-context 11,921 65,536 Published
Stage 4 Think SFT 43,224 32,768 Published
Stage 4 Instruct SFT 3,252 32,768 Published

Checkpoint save and resume, stage transitions, long-context attention, SWA/Full-Attention RoPE separation, and native inference were exercised through the complete 1B pipeline.

Findings: The current evidence supports implementation correctness and end-to-end operability at the 1B scale.

Research Question 2 — Does SiameseNorm + Depth-Attention improve model quality?

Hypothesis: At matched model size, data order, token count, optimizer, learning-rate schedule, batch size, random seed, and evaluation protocol, the modified architecture will improve convergence and downstream evaluation without introducing instability.

Results & Analysis:

The matched 1B training curves show faster loss reduction for SiameseNorm + Depth-Attention during the earlier portion of training. This indicates a potential optimization or sample-efficiency benefit.

However, the final objective downstream evaluation is nearly tied. The modified model reaches a macro average of 36.9, compared with 36.8 for the matched OLMo 3 1B baseline, corresponding to an aggregate difference of approximately +0.1 points.

Benchmark OLMo 2 1B pure SFT Matched OLMo 3 1B baseline SiameseNorm + Depth-Attention Modified − matched baseline
BBH 32.8 37.3 38.9 +1.6
DROP 33.8 36.2 31.3 -4.9
GSM8K 52.1 53.5 51.5 -2.0
IFEval (loose) 50.5 63.6 70.1 +6.5
MATH 13.2 8.0 10.0 +2.0
MMLU 36.4 44.8 40.6 -4.2
PopQA 12.7 11.3 9.6 -1.7
TruthfulQA 42.1 40.0 43.2 +3.2
8-task macro average 34.2 36.8 36.9 +0.1

The modified model outperforms the matched OLMo 3 baseline on four tasks:

  • IFEval: +6.5
  • TruthfulQA: +3.2
  • MATH: +2.0
  • BBH: +1.6

It underperforms on the remaining four tasks:

  • DROP: -4.9
  • MMLU: -4.2
  • GSM8K: -2.0
  • PopQA: -1.7

The published OLMo 2 1B pure-SFT results are retained only as an external reference. They are not a matched architectural control because the model family and training recipe differ.

Findings: SiameseNorm + Depth-Attention shows faster early-stage convergence and meaningful gains on selected tasks, particularly IFEval. Nevertheless, the final 1B aggregate result is only marginally above the matched baseline. The current evidence supports an early-convergence benefit but does not yet demonstrate a substantial final downstream-quality improvement.

Research Question 3 — Does the result generalize beyond 1B?

Hypothesis: The combined architecture remains stable and beneficial at larger model scales.

Results & Analysis:

Model scale Status Current scope
1B Complete Four-stage modified model, matched baseline, and downstream evaluation completed
3B In progress Modified pretraining experiment is still running
7B Suspended Experimental plan is currently suspended

No completed larger-scale matched comparison is available yet.

Findings: Generalization beyond 1B remains unresolved. The 3B experiment will complete before determining whether the faster early convergence and task-level changes observed at 1B persist at a larger scale. The suspended 7B plan is not currently contributing experimental evidence.

Archive


Reviewer Assessment (for repo reviewers)

Draft status remains recommended.

The implementation and 1B end-to-end pipeline are available for review. The matched 1B experiment indicates faster early convergence, but the final eight-task macro average is nearly tied with the OLMo 3 baseline.

The modified 3B experiment remains in progress, while the 7B experimental plan is suspended. Larger-scale validation is therefore incomplete, and no general architectural-effectiveness claim is made at this stage.

Merge Checklist:

  • The implementation PR is linked to an in-progress Architecture Proposal issue ([ARCH-PROP] SiameseNorm&Depth-Attention #2).
  • Implementation correctness is verified at 1B through four-stage training, checkpoint-transition, and inference validation.
  • A matched OLMo 3 1B baseline comparison has been completed.
  • The modified 3B training and downstream evaluation are complete.
  • The effectiveness of the proposed architecture is validated at the agreed larger-model scale.
  • The archive information is complete, including final WandB reports and Hugging Face collections for all required model scales.

@RmZeta2718 RmZeta2718 added the architecture implementation A pull request implementing an approved architecture proposal. label Jul 29, 2026
@Knlife

Knlife commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator
  1. Please move the Megatron-LM/ training code to the /reproduce directory.
  2. Provide the modeling code in HuggingFace format in the arch/ directory, and it may look like as follows,
ArchSpace
├── README.md
├── reproduce <- dir for reproducible training and evaluation codes
└── archs     <- dir for architectures
    ├── olmo3
    │   ├── configuration_olmo3.py
    │   └── modeling_olmo3.py
    ├── qwen3
    │   ├── configuration_qwen3.py
    │   └── modeling_qwen3.py
    └── olmo3-siamese-depth-attn
        ├── configuration_olmo3_siamese_depth.py
        └── modeling_olmo3_siamese_depth.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture implementation A pull request implementing an approved architecture proposal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants